package com.a214.yxz.yuejian013.Adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.a214.yxz.yuejian013.JavaBean.MasterQue;
import com.a214.yxz.yuejian013.R;

import java.util.List;

/**
 * Created by YXZ on 2017/11/13.
 */

public class MasterQueAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>{
    private Context mContext;//承载上下文
    private List<MasterQue> mDataList;//动态数组承载数据使用
    private LayoutInflater mLayoutInflater;

    public  MasterQueAdapter(Context mContext,List<MasterQue> mDataList){
        this.mContext=mContext;
        this.mDataList=mDataList;
        mLayoutInflater=LayoutInflater.from(mContext);
    }
    @Override
    public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View v=mLayoutInflater.from(parent.getContext()).inflate(R.layout.masterque,parent,false);
        return new  MasterQueAdapter.ViewHolder(v);
    }

    @Override
    public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
        final MasterQue entity=mDataList.get(position);
        if (null==entity)
            return;
        MasterQueAdapter.ViewHolder viewHolder= (MasterQueAdapter.ViewHolder) holder;
        viewHolder.user_id.setText(entity.getUser_id());
        viewHolder.que.setText(entity.getQuestion());
    }

    @Override
    public int getItemCount() {
        return  mDataList.size();
    }
    public class ViewHolder extends RecyclerView.ViewHolder{

        TextView user_id;
        TextView que;
        public ViewHolder(View itemView) {
            super(itemView);
            user_id= (TextView) itemView.findViewById(R.id.user_id);
            que= (TextView) itemView.findViewById(R.id.que);
        }
    }
}
